/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package centralehotel.modele;

import centralehotel.modele.Client;
import centralehotel.modele.Agence;
import centralehotel.modele.Chambre;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Mathieu
 */
@Entity
@Table(name = "reservation")
@NamedQueries({
    @NamedQuery(name = "Reservation.findByIdReservation", query = "SELECT r FROM Reservation r WHERE r.idReservation = :idReservation"), 
    @NamedQuery(name = "Reservation.findByDateEntree", query = "SELECT r FROM Reservation r WHERE r.dateEntree = :dateEntree"),
    @NamedQuery(name = "Reservation.findByDateSortie", query = "SELECT r FROM Reservation r WHERE r.dateSortie = :dateSortie")
})
public class Reservation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "id_reservation", nullable = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer idReservation;
    @Column(name = "date_entree")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateEntree;
    @Column(name = "date_sortie")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateSortie;
    @JoinColumn(name = "client", referencedColumnName = "id_client")
    @ManyToOne
    private Client client;
    @JoinColumn(name = "agence", referencedColumnName = "id_agence")
    @ManyToOne
    private Agence agence;
    @JoinColumn(name = "chambre", referencedColumnName = "id_chambre")
    @ManyToOne
    private Chambre chambre;

    public Reservation() {
    }

    public Reservation(Integer idReservation) {
        this.idReservation = idReservation;
    }

    public Integer getIdReservation() {
        return idReservation;
    }

    public void setIdReservation(Integer idReservation) {
        this.idReservation = idReservation;
    }

    public Date getDateEntree() {
        return dateEntree;
    }

    public void setDateEntree(Date dateEntree) {
        this.dateEntree = dateEntree;
    }

    public Date getDateSortie() {
        return dateSortie;
    }

    public void setDateSortie(Date dateSortie) {
        this.dateSortie = dateSortie;
    }

    public Client getClient() {
        return client;
    }

    public void setClient(Client client) {
        this.client = client;
    }

    public Agence getAgence() {
        return agence;
    }

    public void setAgence(Agence agence) {
        this.agence = agence;
    }

    public Chambre getChambre() {
        return chambre;
    }

    public void setChambre(Chambre chambre) {
        this.chambre = chambre;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idReservation != null ? idReservation.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Reservation)) {
            return false;
        }
        Reservation other = (Reservation) object;
        if ((this.idReservation == null && other.idReservation != null) || (this.idReservation != null && !this.idReservation.equals(other.idReservation))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "centralehotel.exception.Reservation[idReservation=" + idReservation + "]";
    }

}
